import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
    state: () => ({
        name: '',
        email: '',
        isLoggedIn: false
    }),
    getters: {
        userFullName: state => `${state.name} (${state.email})`
    },
    actions: {
        login(name, email) {
            this.name = name
            this.email = email
            this.isLoggedIn = true
        },
        logout() {
            this.name = ''
            this.email = ''
            this.isLoggedIn = false
        }
    },
    persist: true // 这将启用状态持久化
})
